home *** CD-ROM | disk | FTP | other *** search
/ Suzy B Software 2 / Suzy B Software CD-ROM 2 (1994).iso / picmanip / pic_r2z / showspec / show512.txt < prev   
Text File  |  1995-05-05  |  6KB  |  143 lines

  1.  Object code modules for decompression and display of Spectrum pictures
  2.  
  3.  
  4. Note:  these  modules can not be used as part of any  commercial  product 
  5. without approval of Trio Engineering, inc.
  6.  
  7.  
  8.  
  9.      The modules can be executed from any program that passes  parameters 
  10. on  the stack like in C (examples below are in GFA Basic).  They work  in 
  11. both medium and low resolution (color only).
  12.  
  13.      If you want to show an .SPU (uncompressed) Spectrum picture, you can 
  14. do  it right away with the SHOW512.O module.  .SPC  (compressed)  picture 
  15. files have to be decompressed first using DECOMP.O module.
  16.  
  17.      First thing you should do is to reserve memory for the module(s) and 
  18. the  picture  files.  The  amount  of  memory  required  by  the  modules 
  19. themselves  is  equal  to their size as  disk  files.  Each  uncompressed 
  20. Spectrum picture takes 51104 bytes. Compressed files can be anywhere from 
  21. 2K to 50014 bytes.
  22.  
  23.      Next load the modules themselves.  The code is position-independent, 
  24. so  you  can  load them simply as data files  with  BLOAD.  The  starting 
  25. address for each module must be even, of course.
  26.  
  27.      If you want to decompress an .SPC file first load it to memory (even 
  28. address!).  The  decompressor works memory-to-memory,  it does  not  load 
  29. files from disk. Call the decompressor with the following command:
  30.  
  31. A=C:DECOM%(L:SPC%,L:BITM%,L:COLM%)
  32.  
  33.      DECOM%=Address of the DECOMP.O module
  34.      SPC%=address of the SPC file
  35.      BITM%=address of the decompressed bit map (must be divisible by 256)
  36.      COLM%=address of the decompressed color map (must be even)
  37.  
  38.      A=0 if OK, -1 if decompression error (bad SPC file)
  39.  
  40.  
  41.      The decompressor creates two separate blocks of data: 32000-byte bit 
  42. map at BITM% and 19104-byte color map at COLM%. You can put them anywhere 
  43. you  want,  they don't have to follow immediately one  another  (although 
  44. this is one of the obvious possibilities). 
  45.  
  46.      An  .SPU  file is simply a bit map followed immediately by  a  color 
  47. map.  Load it at any address in memory divisible by 256 (SPU%),  and then 
  48. you'll have:
  49.  
  50.      BITM%=SPU%
  51.      COLM%=SPU%+32000
  52.  
  53.      You also can load the first 32000 bytes of the .SPU file  separately 
  54. from the last 19104 bytes, to two different locations in memory. 
  55.  
  56.      When  both the bitmap and the color map are in memory you  can  call 
  57. the  SHOW512.O module to display the picture on the  screen.  Here's  the 
  58. command to do it:
  59.  
  60.  
  61.      VOID C:SHOW%(1,L:BITM%,L:COLM%)
  62.  
  63.  
  64.      SHOW%=address of the SHOW512.O module
  65.  
  66.  
  67.      To turn the 512-color display off call the SHOW512.O module with the 
  68. single parameter 0:
  69.  
  70.      VOID C:SHOW%(0)
  71.  
  72.  
  73.  
  74.      When you turn the 512-color display off,  SHOW512.O switches to  the 
  75. initial screen (restoring the color palette and resolution if necessary). 
  76. The  initial  screen itself will not be altered,  unless you used  it  to 
  77. store  the bit map portion of the .SPC or .SPU file (which  is  perfectly 
  78. all right to do). In this case make your program redraw its main screen.
  79.  
  80.  
  81.      The mouse is disabled while the 512-color display is on.  You should 
  82. not  try  to  enable it during this period - it will  not  work  properly 
  83. anyway.  You  can only use the keyboard to control the program while  the 
  84. 512 display is on.
  85.  
  86.  
  87.      If  you  have several pictures in memory at the same  time  you  can 
  88. switch between them instantly without turning the 512-color display  off. 
  89. First,  you  have to load each of them to a separate location  in  memory 
  90. (and  decompress  if  necessary).  Start to show  the  first  picture  as 
  91. described  above,  then continue to call the SHOW512.O module in  exactly 
  92. the same way:
  93.  
  94.      VOID C:SHOW%(1,L:BITM2%,L:COLM2%)
  95.  
  96.      Use different addresses BITM% and COLM% with each new call.  At  the 
  97. end turn the 512 display off as described above.
  98.  
  99.  
  100.      Of  course,  you  can make the display time for  each  picture  very 
  101. short  to create page-flip animations.  It's easy to control  the  timing 
  102. precisely.  When you call the SHOW512.O module it returns control to your 
  103. program with a 1/60 sec delay.  Therefore,  if you just make a series  of 
  104. calls:
  105.  
  106.      VOID C:SHOW%(1,L:BITM1%,L:COLM1%)
  107.  
  108.      VOID C:SHOW%(1,L:BITM2%,L:COLM2%)
  109.  
  110.      ................................
  111.  
  112.  
  113.      you'll have a 60 frames per second animation.  To slow it down  make 
  114. one or more VSYNC calls between calls to the SHOW512.O module. Each VSYNC 
  115. delays the previous picture display for another 1/60 of a  second.  VSYNC 
  116. is the same as VOID XBIOS(37).
  117.  
  118.      If you want to synchronize picture switching with some other process 
  119. (Stereotek glasses,  for instance) keep in mind that the SHOW512.O module 
  120. always delays switching for one frame. Here's the timetable:
  121.  
  122. (1)  You call SHOW512.O with the new picture address.  It always  happens 
  123.      when the electron beam is somewhere between the 200-th line and  the 
  124.      screen bottom (at any other time the 512-color interrupt routine  is 
  125.      executed and your program stands still).
  126.  
  127. (2)  The current scan continues to the bottom of the screen
  128.  
  129. (3)  The next scan starts - still showing the _old_ picture
  130.  
  131. (4)  The  200-th  line  is reached.  SHOW512.O returns  control  to  your 
  132.      program. The next scan will show the new picture.
  133.  
  134.  
  135.  
  136.      If  you  use  GFA Basic do not call the SHOW512.O  module  from  the 
  137. direct  mode.  After executing any direct command GFA Basic  returns  the 
  138. screen resolution to medium,  overriding the low resolution mode selected 
  139. by SHOW512.O.  For the same reason you should write your Basic program in 
  140. such  a  way  that  it always turns  the  512-color  display  off  before 
  141. returning control to the user.
  142.  
  143.